﻿@model Models.Models.Coupon

@{
    var types = new WebApp.Services.ServiceService().GetLookUp("CouponType");
    var typeList = new SelectList(types.LookUpList, "Key", "Value");
}

<script>
    $(document).ready(function () {
        $("#ExpirationDate").attr('readonly', 'readonly');
        $("#ExpirationDate").css('cursor', 'pointer');
        $("#ExpirationDate").addClass('input-small');

        $("#ExpirationDate").datepicker({
            showAnim: 'slideDown',
            dateFormat: 'mm/dd/yy'
        });
    });
</script>

@using (Ajax.BeginForm(Model.ID == 0 ? "CreateCoupon" : "EditCoupon", "Coupon", null, new AjaxOptions(), new { @id = "formCoupon", @class = "form-horizontal" }))
{        
        <fieldset style="height: 500px; border-style: ridge; border-width: 1px; border-color: #DDDDDD;">
                @Html.ValidationSummary()

                @Html.HiddenFor(model => model.ID)
                @Html.HiddenFor(model => model.DomainID)

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.eCommCouponID)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.eCommCouponID, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.Description)</label>
                    <div class="controls">@Html.TextAreaFor(m => m.Description, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.Value)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.Value, new { @class = "input-small" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.MinOrderAmount)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.MinOrderAmount, new { @class = "input-small" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.MaxOrderAmount)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.MaxOrderAmount, new { @class = "input-small" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.TypeID)</label>
                    <div class="controls">@Html.DropDownListFor(m => m.TypeID, typeList, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.Message)</label>
                    <div class="controls">@Html.TextAreaFor(m => m.Message, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.ExpirationDate)</label>
                    <div class="controls"><div class="input-append">@Html.EditorFor(m => m.ExpirationDate, "", new { @id = "datePicker", @class = "datePicker" })</div></div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.LimitedNumber)</label>
                    <div class="controls">@Html.EditorFor(m => m.LimitedNumber) @Html.TextBoxFor(m => m.Uses, new { @class = "input-small" })</div>
                </div>

        </fieldset>            
    <br />
    {
        var rights = new WebApp.Classes.UserRights("Coupon Settings");

        if (rights.FullControl || rights.Editable)
        { 
                    <div class="">
                        @if (!Model.RevokeStatus)
                        {
                            if (Model.ID == 0)
                            {
                                <button type="submit" class="btn btn-inverse" id="createCoupon"><i class="icon-ok icon-white"></i> Create</button>            
                            }
                            else
                            { 
                                <button type="submit" class="btn btn-inverse" id="updateCoupon"><i class="icon-ok icon-white"></i> Update</button>                                        
                            }
                        }
                        @if (Model.ID != 0)
                        {
                            if (Model.RevokeStatus)
                            {
                                <button type="button" class="btn btn-inverse" id="activate"><i class="icon-repeat icon-white"></i> Activate</button>
                            }
                            else
                            {                            
                                <button type="button" class="btn btn-inverse" id="revoke"><i class="icon-remove icon-white"></i> Revoke</button>
                            }
                        }
                    </div>
        }
    }
}